import { formatter } from 'element-plus';

export const columns = [
  {
    prop: 'productId',
    label: '商品ID',
    width: 180,
    search: true
  },
  {
    prop: 'productName',
    label: '商品名称',
    width: 200,
    search: true,
    slot: 'productSlot'
  },
  {
    prop: 'productSpec',
    label: '商品规格',
    search: true
  },
  {
    prop: 'productTitle',
    label: '商品标题',
    search: true
  },
  {
    prop: 'productImage',
    label: '商品/套餐图',
    slot: 'productImageSlot',
    width: 200,
    search: true
  },
  {
    prop: 'productUnitNum',
    width: 100,
    label: '商品数量',
    slot: 'productUnitNumSlot'
  },
  {
    prop: 'price',
    label: '价格',
    slot: 'priceSlot'
  },

  {
    prop: 'stock',
    label: '商品库存',
    formatter: (row) => {
      // 如果是组合套餐 不展示库存
      if (parseInt(row.stock) <= 0) {
        return '';
      }
      return row.stock;
    }
  },
  {
    prop: 'remark',
    label: '备注'
  },
  {
    prop: 'operation',
    label: '操作',
    fixed: 'right',
    slot: 'operationSlot',
    width: 120
  }
];
